\documentclass[type=master]{bithesis}

\BITSetup{
  % 在目录页中不显示摘要和主要符号对照表的标题。
  TOC = {
    abstract = false,
    abstractEn = false,
    symbols = false,
  },
  % 采用章节标题级别的附录格式
  appendices / chapterLevel = true,
  style = {
    head = \BIThesis \isGraduateTF{研究生学位论文}{本科生毕业设计（论文）} \LaTeX 模板快速使用指南,
    pageVerticalAlign = top,
    % 开启 Windows 平台下的中易宋体伪粗体。
    % windowsSimSunFakeBold = true,
  },
  misc/hideLinks = false,
}

\usepackage{booktabs}
\usepackage{hologo}
\usepackage{float}
\usepackage{caption}
\usepackage{dirtree}
\usepackage{upgreek}
\usepackage{subcaption}

\usepackage{relsize}
\makeatletter
\def\matex@ssize{\smaller\scshape}
\DeclareRobustCommand{\BIThesis}{
  \texorpdfstring{\mbox{
      \kern-0.5em{B}\kern-0.05em
      {I}\kern-0.05em
      {T}\kern-0.1em
      \raisebox{-0.38ex}{\matex@ssize {H}}\kern-0.1em
      {\matex@ssize {E}}\kern-0.05em
      \raisebox{-0.38ex}{\matex@ssize {S}}\kern-0.05em
      {\matex@ssize {I}}\kern-0.05em
      \raisebox{-0.35ex}{\matex@ssize {S}}\kern-0.5em
      \kern 1ex
     }}{BIThesis}
}
\makeatother

\usepackage[
  defernumbers=true,
  backend=biber,
  style=gb7714-2015,
  gbalign=gb7714-2015,
  gbnamefmt=lowercase,
  gbpub=false,
  gbannote=true,
  gbpunctin=false,
  doi=false,
  url=false,
  eprint=false,
  isbn=false,
]{biblatex}

\addbibresource{reference/main.bib}

\usepackage{hyperref}
% https://bithesis.bitnp.net/faq/autoref-name.html
\def\figureautorefname~#1\null{图~#1~\null}
\def\chapterautorefname~#1\null{第~#1~章\null}
\def\sectionautorefname~#1\null{第~#1~节\null}
\def\subsectionautorefname~#1\null{第~#1~节\null}
\def\equationautorefname~#1\null{式~(#1)~\null}

\ExplSyntaxOn

\NewDocumentCommand{\getenv}{om}
 {
  \sys_get_shell:nnN { kpsewhich ~ --var-value ~ #2 } { } \l_tmpa_tl
  \tl_trim_spaces:N \l_tmpa_tl
  \IfNoValueTF { #1 }
   {
    \tl_use:N \l_tmpa_tl
   }
   {
    \tl_set_eq:NN #1 \l_tmpa_tl
   }
 }

 \tl_gset:Nn \GRADUATE {}
 \getenv[\GRADUATE]{GRADUATE}

  % 若为研究生，显示第一个参数；若为本科生，显示第二个参数。
  % 命令内部不能使用 lstlisting 环境，原因如下。可用 \lstinputlisting 绕开。
  % Verbatim material can't be placed in a macro argument because then the material got already parsed by TeX and the switching to verbatim mode comes to late.
  % https://tex.stackexchange.com/a/122055
 \NewDocumentCommand{\isGraduateTF}{ m m } {
   \str_if_eq:VnTF \GRADUATE { true } { #1 } { #2 }
 }

\ExplSyntaxOff

\begin{document}

\input{chapters/cover.tex}

\frontmatter

\MakeTOC

\mainmatter

\input{chapters/ch0-quick-start.tex}
\input{chapters/ch1-intro.tex}
\input{chapters/ch2-template-usage.tex}
\input{chapters/ch3-latex-syntax.tex}

\begin{bibprint}
  \printbibliography[heading=none,notcategory=mypub,resetnumbers=true]
\end{bibprint}

\backmatter

\input{chapters/conclusion.tex}

\input{chapters/appendices.tex}

\input{chapters/acknowledgements.tex}

\end{document}
